<?php 
$doNotAuth = true;
include_once(dirname(__FILE__)."/../inc/common.php"); 
include_once(dirname(__FILE__)."/function.php"); 
@session_start();

$cfg_use_vdcode='否';
$cfg_dbprefix="";
$pageSize = 50;

if (!isset($loging) || $loging!=1){
	check_login();
}
$db = ext_dbHandle::getDb();


function ShowMsg($msg,$gourl,$onlymsg=0,$limittime=0){
		$htmlhead  = "<html>\r\n<head>\r\n<title>提示信息</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n";
		$htmlhead .= "<base target='_self'/>\r\n</head>\r\n<body leftmargin='0' topmargin='0'>\r\n<center>\r\n<script>\r\n";
		$htmlfoot  = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n";
		
		if($limittime==0) $litime = 1000;
		else $litime = $limittime;
		
		if($gourl=="-1"){
			if($limittime==0) $litime = 5000;
			$gourl = "javascript:history.go(-1);";
		}
		
		if($gourl==""||$onlymsg==1){
			$msg = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n<script>alert(\"".str_replace("\"","“",$msg)."\");location='login.php';</script>";
		}else{
			$func = "      var pgo=0;
      function JumpUrl(){
        if(pgo==0){ location='$gourl'; pgo=1; }
      }\r\n";
			$rmsg = $func;
			$rmsg .= "document.write(\"<br/><div style='width:400px;padding-top:4px;height:24;font-size:10pt;border-left:1px solid #7ECDFB;border-top:1px solid #7ECDFB;border-right:1px solid #7ECDFB;background-color:#ACE4FF;'>提示信息！</div>\");\r\n";
			$rmsg .= "document.write(\"<div style='width:400px;height:100;font-size:10pt;border:1px solid #7ECDFB;background-color:#EEFAFE'><br/><br/>\");\r\n";
			$rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");\r\n";
			$rmsg .= "document.write(\"";
			if($onlymsg==0){
				if($gourl!="javascript:;" && $gourl!=""){ $rmsg .= "<br/><br/><a href='".$gourl."'>如果你的浏览器没反应，请点击这里...</a>"; }
				$rmsg .= "<br/><br/></div>\");\r\n";
				if($gourl!="javascript:;" && $gourl!=""){ $rmsg .= "setTimeout('JumpUrl()',$litime);"; }
			}else{ $rmsg .= "<br/><br/></div>\");\r\n"; }
			$msg  = $htmlhead.$rmsg.$htmlfoot;
		}		
		echo $msg;
}

function check_login()
{
	global $msg,$options;
	if (!isset($_SESSION["admin_name"]) || !isset($_SESSION["admin_id"]) 
		|| $_SESSION["admin_name"]=="" || $_SESSION["admin_id"]==""){
		//ShowMsg("您还没有登录！","login.php",0,1000);
		//exit;
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n<script>alert(\"您还没有登录!\");parent.location=\"login.php\";</script>";
		exit;
	}
	
	if ($_SESSION["admin_id"]!=1)
	{
		$gotopage="/index.php";
		//ShowMsg("成功登录，正在转向管理主页！",$gotopage);
		//exit();
		//echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n<script>parent.location=\"".$gotopage."\";</script>";
		//exit;
	}
}

function GetEditor($fname,$fvalue,$nheight="350",$etype="Basic",$gtype="print",$isfullpage="false")
{
	
	if(!isset($GLOBALS['cfg_html_editor'])) $GLOBALS['cfg_html_editor']='fck';
	if($gtype=="") $gtype = "print";
	if($GLOBALS['cfg_html_editor']=='fck'){
	  require_once(dirname(__FILE__)."/../include/fckeditor4/fckeditor.php");
	  $fck = new FCKeditor($fname);
	  $fck->BasePath		= $GLOBALS['cfg_cmspath'].'/include/fckeditor/' ;
	  $fck->Width		= '100%' ;
	  $fck->Height		= $nheight ;
	  $fck->ToolbarSet	= $etype ;
	  $fck->Config['FullPage'] = $isfullpage;
	  if($GLOBALS['cfg_fck_xhtml']=='是'){
	  	$fck->Config['EnableXHTML'] = 'true';
	    $fck->Config['EnableSourceXHTML'] = 'true';
	  }
	  $fck->Value = $fvalue ;
	  if($gtype=="print") $fck->Create();
	  else return $fck->CreateHtml();
  }else{
		require_once(dirname(__FILE__)."/../include/htmledit/dede_editor.php");
	  $ded = new DedeEditor($fname);
	  $ded->BasePath		= $GLOBALS['cfg_cmspath'].'/include/htmledit/' ;
	  $ded->Width		= '100%' ;
	  $ded->Height		= $nheight ;
	  $ded->ToolbarSet = strtolower($etype);
	  $ded->Value = $fvalue ;
	  if($gtype=="print") $ded->Create();
	  else return $ded->CreateHtml();
	}
}
?>